##############################################################
## MOD Title: Release Wizard v2.01 for TorrentPier r775
## MOD Author: pservit, RoadTrain (http://torrentpier.info/)
## MOD Version: 2.01
## Installation Level: Easy
## Installation Time: 2 Minutes
## Files To Edit: common.php
##				  includes/cron/jobs/avatars_cleanup.php
## Included Files:  release.php
##                  release_cfg.php
##                  release.js
##                  photos/viewimg.php
##                  photos/.htaccess
##                  photos/error.gif
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
##############################################################
## Author Notes:
## http://torrentpier.info/
##############################################################
## MOD History:
##    2008-10-24 - Version 2.01
##    	- initial release
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

# 
#-----[ COPY ]---------------------------------
#
\root\*.* to *.*

# 
#-----[ SQL ]---------------------------------
# 
CREATE TABLE IF NOT EXISTS `bb_photos` (
  `id` mediumint(8) NOT NULL auto_increment,
  `user_id` mediumint(8) NOT NULL default '-1',
  `filename` varchar(255) NOT NULL default '0',
  `viewed` mediumint(8) NOT NULL default '0',
  `added` int(11) NOT NULL,
  `last_viewed` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

# 
#-----[ OPEN ]---------------------------------
# 
common.php

# 
#-----[ FIND ]---------------------------------
#
define('BT_USERS_TABLE',    $table_prefix .'bt_users');

# 
#-----[ AFTER, ADD ]---------------------------------
#
define("PHOTOS_TABLE", $table_prefix .'photos');

# 
#-----[ OPEN ]---------------------------------
# 
includes/cron/jobs/avatars_cleanup.php


# 
#-----[ FIND ]---------------------------------
#
unset($fix_errors, $debug_mode);


# 
#-----[ AFTER, ADD ]---------------------------------
#
$photo_prune_time = time() - 2592000; //-30 days

$sql = "SELECT filename FROM ". PHOTOS_TABLE ." WHERE last_viewed < $photo_prune_time";
if ($result = $db->sql_query($sql)) 
{
	while ($row = $db->sql_fetchrow($result))
	{
		$img = $row['filename'];
		if (file_exists(BB_ROOT."photos/".$img))
		{
			@unlink(BB_ROOT."photos/".$img);
		}		
	}
	$db->query("DELETE FROM ". PHOTOS_TABLE ." WHERE last_viewed < $photo_prune_time");
}


#
#-----[ SAVE/CLOSE ALL FILES ]---------------------------------
#
# EoM
